package com.fc.campusapplicationsystem.service;

import com.fc.campusapplicationsystem.mapper.ReplyMapper;
import com.fc.campusapplicationsystem.model.Reply;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author kyc
 * @2020-06-10 15:14
 */
@Service
public class ReplyServiceImpl implements ReplyService {

    @Autowired
    ReplyMapper replyMapper;

    @Autowired
    ReListService reListService;

    @Override
    public List<Reply> list() {
        return replyMapper.selectAll();
    }

    @Override
    public Integer add(Reply reply) {
        Integer result = reListService.update(reply.getReId());
        if (result!=1){
            return result;
        }
        return replyMapper.insertSelective(reply);
    }

    @Override
    public Reply getReplyByReListId(Integer reId) {
        return replyMapper.selectByPrimaryKey(reId);
    }
}
